package com.kbckbc.easyhangul;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class SplashActivity extends Activity {

	private Thread mSplashThread;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
	

	    final SplashActivity sPlashScreen = this;   

	    // The thread to wait for splash screen events
	    mSplashThread =  new Thread(){
	        @Override
	        public void run(){
	            try {
	                synchronized(this){
	                    // Wait given period of time or exit on touch
	                    wait(3000);
	                }
	            }
	            catch(InterruptedException ex){                    
	            }

	            finish();

	            // Run next activity
	            Intent intent = new Intent();
	            intent.setClass(sPlashScreen, MainActivity.class);
	            startActivity(intent);

	        }
	    };

	    mSplashThread.start(); 
	}

    /**
     * Processes splash screen touch events
     */
    @Override
    public boolean onTouchEvent(MotionEvent evt)
    {
        if(evt.getAction() == MotionEvent.ACTION_DOWN)
        {
            synchronized(mSplashThread){
                mSplashThread.notifyAll();
            }
        }
        return true;
    }   
}
